M365 onboarding with Location-Based Routing and Custom Networks

The M365 onboarding with LBR and Custom Networks is shown below. Variables highlighted in orange should be changed according to customer deployment. The custom script arguments used in this script are:

IP-Network
IP-SubnetBits
Trusted-IP-Network
Trusted-IP-SubnetBits
Copy
bypass
# Begin of Microsoft onboarding script


        # Addition for Location based routing


        # Script variables
            [String]$OnlinePstnGateway="{{SBC.OnlinePstnGateway}}"
            [String]$CustomerId="{{SBC.SbcSiteName}}"
            [String]$IPNetwork="{{CustomVar.IP-Network}}"
            [String]$IPSubnet="{{CustomVar.IP-SubnetBits}}"
            [String]$TrustedIPNetwork="{{CustomVar.Trusted-IP-Network}}"
            [String]$TrustedIPSubnet="{{CustomVar.Trusted-IP-SubnetBits}}"


        # PSTN Gateway Variables
        [Int]$SipSignalingPort=5061
        [Int]$MaxConcurrentSessions=100


        # Add Network region if not exists
            if(Get-CsTenantNetworkRegion | Where-Object {$_.Identity -eq "India"})
                {
                    continue
                }else {
                    New-CsTenantNetworkRegion -NetworkRegionID "India";
                }


        # Add Network Site if not exists
            if(Get-CsTenantNetworkSite | Where-Object {$_.Identity -like "{{SBC.SbcSiteName}}"})
                {
                    continue
                }else {
                    New-CsTenantNetworkSite -NetworkSiteID "{{SBC.SbcSiteName}}" -NetworkRegionID "India" -EnableLocationBasedRouting $true -Description "Default Site created by AudioCodes LiveCloud";
                }


        # Add example subnet to the network site
            if(Get-CsTenantNetworkSubnet | Where-Object {$_.Identity -like "{{CustomVar.IP-Network}}"})
                {
                    continue
                }else {
                    New-CsTenantNetworkSubnet -SubnetID "{{CustomVar.IP-Network}}" -MaskBits "{{CustomVar.IP-SubnetBits}}" -NetworkSiteID "{{SBC.SbcSiteName}}" -Description "Subnet set by AudioCodes LiveCloud";
                }


        # Add example trusted IP address
            if(Get-CsTenantTrustedIPAddress | Where-Object {$_.Identity -like "{{CustomVar.Trusted-IP-Network}}"})
                {
                    continue
                }else {
                    New-CsTenantTrustedIPAddress -IPAddress "{{CustomVar.Trusted-IP-Network}}" -MaskBits "{{CustomVar.Trusted-IP-SubnetBits}}" -Description "Trusted IP Address set by AudioCodes LiveCloud";
                }


        # Add OnlinePSTNGateway
            if(Get-CsOnlinePSTNGateway | Where-Object {$_.Identity -like "{{SBC.OnlinePstnGateway}}"})
                {
                    continue
                }else {
    
                # The line below might require customization based on the customer needs, like a change in the SipSignalingPort or attributes needs to be added like MaxConcurrentSessions
                      New-CsOnlinePstnGateway -Fqdn "{{SBC.OnlinePstnGateway}}" -Enabled $true -SipSignalingPort $SipSignalingPort -ForwardCallHistory $True -ForwardPai $True -MediaBypass $True -MaxConcurrentSessions $MaxConcurrentSessions -GatewaySiteLbrEnabled $true –GatewaySiteID "{{SBC.SbcSiteName}}" ;
                }


        # Create CallingPolicy named UMPPreventTollBypass
            if(Get-CsTeamsCallingPolicy | Where-Object {$_.Identity -like "Tag:UMPPreventTollBypass"})
                {
                    continue
                }else {
                    New-CsTeamsCallingPolicy -Identity "UMPPreventTollBypass" -AllowCallForwardingToPhone $True -Description "Allow Teams calling, preventing toll bypass" -PreventTollBypass $True;
                }
  

        # End addition for Location based routing


        # From original onboarding script


        # Add PSTN Usage record Unrestricted if not exists
            if(Get-CsOnlinePstnUsage | Where-Object Usage -NotContains "Unrestricted"
                {
                    Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="Unrestricted"};
                }


        # Add Online Voice Route Unrestricted if not exists, else add additional PSTN Gateway to the OnlinePstnGatewayList if there is a new PSTN Gateway
            if(Get-CsOnlineVoiceRoute | Where-Object {$_.Identity -eq "Unrestricted"})
                {
                    Write-host "The CsOnlineVoiceRoute named Unrestricted already exists."
                    if(Get-CsOnlineVoiceRoute -Identity "Unrestricted" | Where-Object {$_.OnlinePstnGatewayList -NotContains "{{SBC.OnlinePstnGateway}}"})
                    {
                        Write-host "A new PSTN Gateway is added to the the OnlinePstnGatewayList."
                        Set-CsOnlineVoiceRoute -Identity "Unrestricted" -OnlinePstnGatewayList  @{add="{{SBC.OnlinePstnGateway}}"}
                    }
                }else {
                    Write-host "The CsOnlineVoiceRoute named Unrestricted does not exist, creating one."
                    New-CsOnlineVoiceRoute -Identity "Unrestricted" -NumberPattern ".*" -OnlinePstnGatewayList @{add="{{SBC.OnlinePstnGateway}}"} -Priority 1 -OnlinePstnUsages @{add="Unrestricted"};
                }


        # Add Voice Routing Policy Unrestricted if not exists
            if(Get-CsOnlineVoiceRoutingPolicy | Where-Object {$_.Identity -like "Tag:Unrestricted"})
                {
                    continue
                }else {
                    New-CsOnlineVoiceRoutingPolicy -Identity "Unrestricted" -OnlinePstnUsages "Unrestricted";
                }


        # End of M365 onboarding script
        ;

When this script is selected in the Onboarding wizard, the Customer Variables pane opens.

Configure the variables as described in the table below.

Customer Variables Values
IP-Network Network IPv4 IP address
IP-SubnetBits For example, 24.
Trusted-IP-Network Trusted IP address range
Trusted-IP-SubnetBits IP subnetBits for this range (32 if only a single IP address)